home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / misc / robots.lha / player / opfer.r < prev    next >
Text File  |  1993-04-25  |  3KB  |  168 lines

  1. Slayer Tech
  2. thb
  3. /* Victim */
  4. /* This is Chuck Norris' digitized */
  5. /* brother...                      */
  6.  
  7.  
  8. main()
  9. {
  10.     int behind;
  11.     int course;
  12.     int dir;
  13.     int dist;
  14.     int scandir;
  15.  
  16.     scandir = 15;
  17.     dir = rand( 359 );
  18.  
  19.     while( 1 ){
  20.  
  21.         course = setcourse();
  22.         drive( course, 100 );
  23.  
  24.         dam = damage();
  25.  
  26.         while( speed() != 0 &&
  27.                loc_y() > 100 && loc_y() < 900 &&
  28.                loc_x() > 100 && loc_x() < 900 ){
  29.  
  30.             if( dam - damage() > 15 ){
  31.                 dodge();
  32.                 dam = damage();
  33.             }
  34.             baller();
  35.         }
  36.         slowdown();
  37.    }
  38.  
  39. }  /* end of main */ 
  40.  
  41.  
  42. baller()
  43. {
  44.     dist = scan( dir, 20 );
  45.     if( dist != 0 ){
  46.         cannon( dir, dist );
  47.     } else {
  48.         dist = scan( dir+10, 20);
  49.         if( dist != 0 ){
  50.             cannon( dir+10, dist );
  51.             dir += 20;
  52.         }
  53.         dist = scan( dir-10, 20);
  54.         if( dist != 0 ){
  55.             cannon( dir-10, dist );
  56.             dir -= 20;
  57.         }
  58.         behind = course + 180;
  59.         dist = scan( behind, 20 );
  60.         if( dist != 0 ){
  61.             cannon( behind, dist );
  62.             dir = behind;
  63.         } else {
  64.             dir += scandir;
  65.         }
  66.     }
  67. }
  68.  
  69.  
  70. dodge()
  71. {
  72.     int dc;
  73.  
  74.     slowdown();
  75.     course = setcourse();
  76.     drive( course, 100 );
  77.     baller();
  78.  
  79. }
  80.  
  81.  
  82. slowdown()
  83. {
  84.     drive(course,48);
  85.     while( speed() >= 49 ) ;
  86. }
  87.  
  88.  
  89. plot(xx,yy)
  90. int xx, yy;
  91. {
  92.   int d;
  93.   int x,y;
  94.   int scale;
  95.   int curx, cury;
  96.  
  97.   scale = 100000;  /* scale for trig functions */
  98.  
  99.   curx = loc_x();
  100.   cury = loc_y();
  101.   x = curx - xx;
  102.   y = cury - yy;
  103.  
  104.   if (x == 0) {
  105.     if (yy > cury)
  106.       d = 90;
  107.     else
  108.       d = 270;
  109.   } else {
  110.     if (yy < cury) {
  111.       if (xx > curx)
  112.         d = 360 + atan((scale * y) / x);
  113.       else
  114.         d = 180 + atan((scale * y) / x);
  115.     } else {
  116.       if (xx > curx)
  117.         d = atan((scale * y) / x);
  118.       else
  119.         d = 180 + atan((scale * y) / x);
  120.     }
  121.   }
  122.   return (d);
  123. }
  124.  
  125.  
  126. int setcourse()
  127. {
  128.     int x;
  129.     int curx;
  130.     int y;
  131.     int cury;
  132.     int retval;
  133.     int atn;
  134.  
  135.     curx = loc_x();
  136.     cury = loc_y();
  137.  
  138.     if( curx < 150 || curx > 850 ||
  139.         cury < 150 || cury > 850 ){
  140.         x = rand(300) + 350;
  141.         y = rand(300) + 350;
  142.     } else {
  143.         if( rand(4) > 2 ){
  144.         /* horizontal */
  145.             x = 150 + rand( 700 );
  146.             if( loc_x() > 500 ){
  147.                 y = 150 + rand( 100 );
  148.             } else {
  149.                 y = 750 + rand( 100 );
  150.             }
  151.         } else {
  152.         /* vertikal */
  153.             y = 150 + rand( 700 );
  154.             if( loc_y() > 500 ){
  155.                 x = 150 + rand( 100 );
  156.             } else {
  157.                 x = 750 + rand( 100 );
  158.             }
  159.         }
  160.         
  161.     }
  162.  
  163.     return( rand( 30 ) + plot( x, y ) );
  164.  
  165. }
  166.  
  167. /* end of opfer.r */
  168.